import React,{Component} from 'react';

function IsLogin(Com){ //main组件
    return class extends Component{
        state = {
            status:false   //登录的状态
        }
        componentDidMount(){
            let token = localStorage.getItem('token');
            if(token){
                this.setState({
                    status:true
                })
            }else{
                //没有登录
                this.props.history.push('/login');
            }
        }
        render(){
            let {status} = this.state;
            return <>{status ? <Com {...this.props}/> :<></>}</>
        }
    }
}

export default IsLogin